package controller

import (
	"fmt"
	"net/http"
	"tiktok2023/model"
	"tiktok2023/service"

	"github.com/gin-gonic/gin"
)

type CommentListResponse struct {
	model.Response
	CommentList []model.Comment `json:"comment_list,omitempty"`
}

type CommentActionResponse struct {
	model.Response
	Comment model.Comment `json:"comment,omitempty"`
}

// CommentAction no practical effect, just check if token is valid
func CommentAction(c *gin.Context) {
	commentService := service.CommentService{}
	resp, err := commentService.HandleCommentAction(c)
	if err != nil {
		c.JSON(http.StatusOK, model.Response{StatusCode: 1, StatusMsg: fmt.Sprintf("err:%v", err)})
		return
	}
	c.JSON(http.StatusOK, resp)
}

// CommentList all videos have same demo comment list
func CommentList(c *gin.Context) {
	commentService := service.CommentService{}
	resp, err := commentService.HandleCommentList(c)
	if err != nil {
		c.JSON(http.StatusOK, model.Response{StatusCode: 1, StatusMsg: fmt.Sprintf("err:%v", err)})
		return
	}
	c.JSON(http.StatusOK, resp)
}
